﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLBenhVien
{
    public partial class PrintHoaDonKhamBenh : Form
    {
        public PrintHoaDonKhamBenh(int sothutu)
        {
            InitializeComponent();
            lbSoThuTu.Text = sothutu.ToString();
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {            
            CaptureScreen();            
            printDocument1.Print();            
        }

        Bitmap memoryImage;

        private void CaptureScreen()
        {
            Graphics myGraphics = this.CreateGraphics();
            Size s = panel1.Size;
            memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);
            memoryGraphics.CopyFromScreen(this.Location.X + 10, this.Location.Y + 30, 0, 0, s);
        }

        private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawImage(memoryImage, 0, 0);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }        
    }
}
